package patterns.command;

import System.Task.Task;

public class StartTaskCommand implements MachineCommand {
        private Task task;

    public StartTaskCommand(Task task) {
            this.task = task;
        }

        @Override
        public void execute() {
            task.start();
            task.addCommand("任务开始执行");
            System.out.println("执行: " + getDescription());
        }

        @Override
        public void undo() {
            task.cancel();
            task.addCommand("任务开始操作被撤销");
            System.out.println("撤销: " + getDescription());
        }

        @Override
        public String getDescription() {
            return "开始任务 " + task.getTaskId();
        }
    }